<?php
/**
 * SocialEngine
 *
 * @category   Application_Extensions
 * @package    Like
 * @copyright  Copyright Hire-Experts LLC
 * @license    http://www.hire-experts.com
 * @version    $Id: AdminSettingsController.php 2010-09-07 16:05 idris $
 * @author     Idris
 */

/**
 * @category   Application_Extensions
 * @package    Like
 * @copyright  Copyright Hire-Experts LLC
 * @license    http://www.hire-experts.com
 */

class Like_AdminSettingsController extends Core_Controller_Action_Admin {
	public function init() {
		$this->view->navigation = $navigation = Engine_Api::_ ()->getApi ( 'menus', 'core' )->getNavigation ( 'like_admin_main', array (), 'like_admin_main_settings' );
	}
	
	public function indexAction() {
		$this->view->form = $form = new Like_Form_Admin_Global ( array ('action' => $this->view->url ( array ('action' => 'index', 'controller' => 'settings', 'module' => 'like' ), 'admin_default' ) ) );
		
		if (! $this->getRequest ()->isPost ()) {
			return;
		}
		
		if (! $form->isValid ( $this->getRequest ()->getPost () )) {
			return;
		}
		
		$api = Engine_Api::_ ()->like ();
		$values = $form->getValues ();
		
		$settings = Engine_Api::_ ()->getApi ( 'settings', 'core' );
		
		$settings->setSetting ( 'like.profile.count', $values ['like_profile_count'] );
		$settings->setSetting ( 'like.profile.period', $values ['like_profile_period'] );
		$settings->setSetting ( 'like.likes.count', $values ['like_likes_count'] );
		$settings->setSetting ( 'like.likes.period', $values ['like_likes_period'] );
		$settings->setSetting ( 'like.matches.count', $values ['like_matches_count'] );
		$settings->setSetting ( 'like.event.count', $values ['like_event_count'] );
		$settings->setSetting ( 'like.event.period', $values ['like_event_period'] );
		$settings->setSetting ( 'like.group.count', $values ['like_group_count'] );
		$settings->setSetting ( 'like.group.period', $values ['like_group_period'] );
		$settings->setSetting ( 'like.user.count', $values ['like_user_count'] );
		$settings->setSetting ( 'like.user.period', $values ['like_user_period'] );
		$settings->setSetting ( 'like.page.count', $values ['like_page_count'] );
		$settings->setSetting ( 'like.page.period', $values ['like_page_period'] );
		
		if ($form->logo->getValue ()) {
			$api->setPhoto ( $form->logo );
		}
	}

}